<?php
/**************************************************
HTML below. No form tag 
(though if you'd like to include another form, 
just close one, and open the new one right after,
like so: </form><form method="post" action="">)
***************************************************/

//Must be included at the top of all mod files.
if(!defined('DREAMSCAPE')){die('Sorry, but this file cannot be directly viewed.');} 
?>
<?php
//If you're adding content, use this block
if(ADDING):							
?>

<label for="online"><?php echo L_ONLINE ?></label>
<input name="online" class="cBox" type="checkbox" id="online" value="1" checked="checked" />
<br />
<label for="title"><?php echo L_TITLE ?></label>
<input name="title" type="text" class="formfields" id="title" size="60" />
<input type="hidden" name="aid" value="<?php echo $_SESSION['id']; ?>" />
<input type="hidden" name="cid" value="<?php echo $catid; ?>" />
<br />
<label for="descr"><?php echo L_BODY ?></label>
<textarea name="descr" id="descr" class="formfields" tabindex=""></textarea>
<br />
<label for="tags"><?php echo L_TAGS ?></label>
<textarea name="tags" id="tags" class="formfields" tabindex=""></textarea>
<br />
<label for="smilies"><?php echo L_USE_SMILIES ?></label>
<input name="smilies" class="cBox" type="checkbox" id="smilies" value="1" checked="checked" />
<br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label>
<input name="comments" class="cBox" type="checkbox" id="comments" value="1" checked="checked" />
<br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
    <?php 
$the_module->more_options(
	array(
	L_CATEGORY_OPTIONS => 'doCategories',
	)
);
$the_module->more_options(L_POST_TIME_ADD, 'doDateTimeForms', 'editDateTimeContainer');
?>
</div>
<label for="add"></label>
<input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_ADD ?>" />
<?php endif; ?>
<?php 
//If you're editing content, use this block
if(EDITING): ?>
<?php if(EDIT_SINGLE):
		?>
<label for="online"><?php echo L_ONLINE ?></label>
<input name="online" type="hidden" id="" value="0" />
<input class="cBox" type="checkbox" name="online" value="1" id="online" <?php echo ($items->online == 1) ? 'checked="checked"' : '';?> />
<br />
<?php echo preview_link(); ?>
<label for="title"><?php echo L_TITLE ?></label>
<input name="title" type="text" class="formfields" id="title" value="<?php echo view($items->title);?>" size="60" />
<br />
<input type="hidden" name="aid" value="<?php echo $items->aid;?>" />
<input type="hidden" name="cid" value="<?php echo $items->cid;?>" />
<br />
<label for="descr"><?php echo L_BODY ?></label>
<textarea name="descr" cols="60" rows="5" id="descr" class="formfields"><?php echo view($items->descr); ?></textarea>
<br />
<label for="tags"><?php echo L_TAGS ?></label>
<textarea name="tags" id="tags" cols="60" rows="3" class="formfields"><?php echo view($items->tags); ?></textarea>
<br />
<label for="smilies"><?php echo L_USE_SMILIES ?></label>
<input type="hidden" name="smilies" value="0" />
<input class="cBox" type="checkbox" name="smilies" value="1" id="smilies" <?php echo ($items->smilies == 1) ? 'checked="checked"' : '';?> />
<br />
<label for="comments"><?php echo L_ALLOW_COMMENTS ?></label>
<input type="hidden" name="comments" value="0" id="" />
<input class="cBox" type="checkbox" name="comments" value="1" id="comments" <?php echo ($items->comments == 1) ? 'checked="checked"' : ''; ?> />
<br />
<?php $the_module->custom_fields(); ?>
<div class="stretchContainer">
  <?php 
$the_module->more_options(
	array(
	L_CATEGORY_OPTIONS => 'doCategories',
	L_CLEAN_URL_TITLES => 'doCleanURLTitles'
	)
);
$the_module->more_options(L_SHARE_ITEM, 'doSharing', 'sharing');
$the_module->more_options(L_POST_TIME_EDIT, 'doDateTimeForms', 'editDateTimeContainer');
?>
</div>
</div>
<br />
<label for="edit"></label><input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_EDIT ?>" />
<?php elseif(EDIT_LIST): ?>
<?php $the_module->doSort(); ?>
<?php
			$itemsList = paginate($itemsList, '', EDIT_LIMIT);
			$numitems = count($itemsList);
			$hasitems = $numitems > 0 ? true : false;
			?>
<div id="itemList">
  <?php 
			foreach($itemsList as $ind => $item):
            $item->title = trim_title($item->title);
            $item->descr = trim_excerpt($item->descr);
			$users->Get($item->aid);
			$the_displayname = $users->displayname;
			$the_username = $users->username;
			$has_subcat = ($item->cid != $item->pid && $item->cid != 0) ? true : false;
			if($has_subcat){
				$sections->Get($item->cid);
				$category = $sections->sectionname;
			}
			?>
  <div id="item_<?php echo $item->id ?>" title="<?php echo $item->descr ?>">
    <h1><?php echo $item->title ?></h1>
    <h2 class="<?php echo ($item->online == 0) ? 'offline' : 'online'; ?>"><?php echo ($item->online == 0) ? L_ITEM_OFFLINE : L_ITEM_ONLINE; ?></h2>
    <h3><?php printf(L_POSTED_BY, $the_displayname, $the_username) ?></h3>
    <?php if($has_subcat){
	 ?>
    <h3><?php echo L_SUB_CATEGORY ?>: <?php echo $category; ?></h3>
    <?php 
	 }
	 ?>
    <a href="<?php echo edit_link($item->id); ?>" title="<?php echo L_EDIT_ITEM ?>"><?php echo L_EDIT_ITEM ?></a> <br />
    <a href="<?php echo edit_link($item->id); ?>#sharing" title="<?php echo L_SHARE_ITEM ?>" class="shareLink"><?php echo L_SHARE_ITEM ?></a>
    <fieldset>
    <label for="item_delete_<?php echo $item->id; ?>"><?php echo L_DELETE_ITEM ?></label>
    <input type="checkbox" name="del[]" value="<?php echo $item->id; ?>" id="item_delete_<?php echo $item->id; ?>" />
    <br />
    </fieldset>
  </div>
  <?php 
			endforeach;
			?>
			
  <input type="hidden" value="<?php echo getOption('sortcats'); ?>" id="order_by" />
</div>
<?php if($hasitems): ?>
<label for="delete"></label>
<input name="submit" type="submit" class="buttons" id="submit" value="<?php echo L_BUTTON_DELETE ?>" /><br />
<?php endif; ?>

<?php endif; ?>
<?php endif; ?>
